<template>
  <div id="home" class="min_width">
    <!-- 头部导航 -->
    <Header :chooseIt="chooseIt"></Header>
    <main class="mainShow">
      <!-- 左侧导航 -->
      <div class="main-left">
        <!-- 多级导航 -->

        <el-aside width="100%" style="color: #333">
          <el-menu default-active="/promotionList" :router="true" :unique-opened='true' v-if="!is_join">
            <el-menu-item
              index="/promotionList"
              :class="{'isActive': active == '/promotionList'}"
              @click="reload()"
            >
              <span slot="title">促销项目</span>
            </el-menu-item>
            <el-menu-item
              index="/promotionAdd"
              :class="{'isActive': (active == '/promotionAdd'  && !edit)}"
              @click="reload()"
            >
              <span slot="title">添加促销项目</span>
            </el-menu-item>
            <el-menu-item
              index="/promotionRecord"
              :class="{'isActive': active == '/promotionRecord' || active == '/promotionRecord' }"
              @click="reload()"
            >
              <span slot="title">促销金明细</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
      </div>

      <!-- 右侧主内容区 -->
      <div class="main-right">
        <transition name="fade">
          <router-view class="view" :key="activeDate"></router-view>
        </transition>
      </div>
    </main>
  </div>
</template>

<script>
import $ from "jquery";
export default {
  name: "promotionManagement",
  data: function() {
    return {
      activeDate: "", //刷新页面
      chooseIt: 12,
      active: "/promotionList",
      headerFixed: true,
      edit: false,
      is_join:false
    };
  },
  created: function() {
	  	this.active = this.$route.path;
      this.getPartner()
  },
   // 提供可注入子组件属性
  provide () {
    return {
      reload: this.reload
    }
  },
  methods: {
    //当前选中状态 reload定义
    reload() {
      // $nextTick() 将回调延迟到下次 DOM 更新循环之后执行
      this.$nextTick(() => {
        this.activeDate = Number(Date.parse(new Date()));
      })
    },
     //获取合伙人信息
      getPartner(){
          var that = this;
          that.$post({
              url:'Partner/Setup/get_partner',
              data:{
              },
              success:function(data){
                  // that.userinfo = data.data;
                  if(data.data.superior_id != '0'){
                      that.is_join = true;
                  }
              }

          })
      },
    //账户信息
    jumpAccountInformation() {
      //this.$router.push('/fundsManagement');
    },
    //退出登录
    logout() {
      var _this = this;
      this.$confirm("确认退出吗?", "提示", {})
        .then(() => {
          _this.$router.push("/");
        })
        .catch(() => {});
    },
    //消息
    jumpInformatica() {
      this.$router.push({
        path: "/"
      });
    },
    //获取屏幕高度
    getHeight() {
      var newHeight = $(window).height() - 100;
      $(".mainShow").css("min-height", newHeight + "px");
    },
    handleSelect(key, keyPath) {
      // console.log(key, keyPath);
    }
  },
  mounted() {
    this.getHeight();
  },
  watch: {
    $route(to) {
      if (to.query && to.query.id > 0) {
        this.edit = true;
      } else {
        this.edit = false;
	  }
      this.active = to.path;
    },
    deep: true
  }
};
</script>

<style>
body {
  margin: 0;
}

#home {
  margin: 0 auto;
}
</style>
